#!/bin/bash
trap may_die 1 3 9 15 

function may_die
{
  SLEEP=`expr $RANDOM % 20`
  SLEEP=2
  echo "Sleeping for $SLEEP seconds (but you don't know that)"
  sleep $SLEEP && exit 10
}

TIME=`expr $RANDOM % 50`
echo "STOPPING MYAPP. (likely to take $TIME seconds, but you don't know that!)"
for i in `seq 1 $TIME`
do
  echo -en "."
  sleep 1
done

exit 20
